package se.gala.games.quetzalcoatl;

import se.gala.api.APICommand;
import se.gala.api.GenericAPICommands;
import se.gala.core.GameId;
import se.gala.utils.GGObject;
import se.gala.utils.MoneyInt;
import se.gala.wallet.BalanceTypes;
import se.gala.wallet.InsufficientFundsException;

public class Player extends GGObject implements ClientCommandRequestor {
	
	se.gala.users.Player p;
	Balance balance;
	
	public Player(String sessionToken) {
		log("NEW PLAYER CREATED :) " + sessionToken);
		// TODO remove me
		p = se.gala.users.Player.initiatePlayer(sessionToken);
		balance = new Balance(p.getBalance());
	}

	public Balance getBalance() {
		return balance;
	}

	public void registerBet(BalanceTypes balanceType,
			MoneyInt amount, GameId game) throws InsufficientFundsException {
		// FIXME
		p.registerBet(balanceType, amount, game);
	}
	
	public void registerWin(BalanceTypes balanceType,
			MoneyInt amount, GameId game) {
		// FIXME
		p.registerWin(balanceType, amount, game);
	}

	public void handleResponseCommand(APICommand command) {
		GenericAPICommands r = GenericAPICommands.getCommandById(command.getId());
		switch (r) {
		case GetBalance_Response :
			// TODO Handle balance requests here
		break;
		default:
			log("UNEXPECTED PLAYER COMMAND: " + command.getKey(), LogLevel.Error);
			break;
		}
	}
}
